package cn.snews.Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import news.News;
import toolDAO.Page;
import dao.NewsDAO;

public class AdminServlet extends HttpServlet {

	private static final long serialVersionUID = -2252787782109162773L;

	public AdminServlet() {
		super();
	}

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");

		int pageNo = 1;// 分页
		try {
			pageNo = Integer.parseInt(request.getParameter("pageNo"));
		} catch (Exception e) {

		}// 忽略所有异常

		Page<News> p = NewsDAO.DAO.find(pageNo);
		request.setAttribute("p", p);

		request.getRequestDispatcher("/WEB-INF/jsp/admin.jsp").forward(request,
				response);
	}

	public void init() throws ServletException {
	}

}
